package com.neusoft.elmboot.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.neusoft.elmboot.po.User;
import com.neusoft.elmboot.po.UserDTO;

@Mapper
public interface UserMapper {

	@Select("select * from user where userId=#{userId} and password=#{password}")
	public User getUserByIdByPass(User user);

	@Select("select * from user where userId=#{userId}")
	public User getUserById(String userId);

	@Insert("insert into user values(#{userId},#{password},#{userName},#{userSex},null,1,#{apiKey},0,0)")
	public int saveUser(User user);

	@Update("update user set userName=#{userName},userSex=#{userSex},userImg=#{userImg} where userId=#{userId} and password=#{password}")
	public int updateUser(User user);

	@Update("delete from user where userId=#{userId}")
	public int deleteUser(User user);

	@Select("SELECT * FROM user WHERE apiKey = #{apiKey}")
	User getUserByApiKey(String apiKey);

	@Update("update user set IsVIP=1 where userId=#{userId}")
	public int VIPUser(User user);
	
}